home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / jpl_c.zip / CALLOC.C < prev    next >
Text File  |  1986-05-18  |  896b  |  27 lines

  1. /* 1.2  07-10-85                         (calloc.c)
  2.  ************************************************************************
  3.  *            Robert C. Tausworthe                *
  4.  *            Jet Propulsion Laboratory            *
  5.  *            Pasadena, CA 91009        1985        *
  6.  ************************************************************************/
  7.  
  8. #include "defs.h"
  9. #include "stdtyp.h"
  10.  
  11. /************************************************************************/
  12.     char *
  13. calloc(nelem, elsize)    /* Return pointer to storage for nelem elements
  14.                of size elsize. Initialize storage to zeros.    */
  15. /*----------------------------------------------------------------------*/
  16. unsigned nelem, elsize;
  17. {
  18.     char *malloc(), *p, *q;
  19.     unsigned i, n_units();
  20.  
  21.     p = q = malloc(i = nelem * n_units(elsize) * sizeof(HEADER));
  22.     if (q /* ISNT NULL */)
  23.         while (i--)
  24.             *q++ = NULL;
  25.     return p;
  26. }
  27.